import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('./views/Home.vue'),
      // a meta field
      meta: { requiresAuth: true, keepAlive: true, showTab: true }
    },
    {
      path: '/hall',
      name: 'hall',
      component: () => import('./views/Hall.vue'),
      // a meta field
      meta: { requiresAuth: true, keepAlive: true, showTab: true }
    },
    {
      path: '/release',
      name: 'release',
      component: () => import('./views/Release.vue'),
      // a meta field
      meta: { requiresAuth: true, keepAlive: true, showTab: true }
    },
    {
      path: '/exhibition',
      name: 'exhibition',
      component: () => import('./views/Exhibition.vue'),
      // a meta field
      meta: { requiresAuth: true, keepAlive: true, showTab: true }
    },
    {
      path: '/mine',
      name: 'mine',
      component: () => import('./views/Mine.vue'),
      // a meta field
      meta: { requiresAuth: true, keepAlive: true, showTab: true }
    }
  ]
})

// router.beforeEach((to, from, next) => {
//   if (to.matched.some(record => record.meta.requiresAuth)) {
//     next();
//     // if (!auth.loggedIn()) {
//     //   // next({
//     //   //   path: '/login',
//     //   //   query: { redirect: to.fullPath }
//     //   // })
//     // } else {
//     //   next()
//     // }
//   } else {
//     next() // 确保一定要调用 next()
//   }
// })

// export default router;